package com.example.share.controller;

import com.example.share.pojo.User;
import com.example.share.service.ReviseUserService;
import com.example.share.util.CommonResult;
import com.example.share.util.ResultCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import sun.security.util.Password;

/**
 * @author haoren
 */
@RestController
public class ReviseUserController {
    @Autowired
    private ReviseUserService reviseUserService;
    //修改信息
    @RequestMapping("/seclet")
    public CommonResult ReviseUser(){
        //public CommonResult<Boolean> ReviseUser(){
        //用户ID，前端传入
        int userId=2;

        User user = reviseUserService.finduser(userId);

        //前端用户输入的数据
        String username;
        String Password;
        String tel;
        String ncikname;

//测试代码  0000结束
        if (user.getUserName().equals("tianian")==false){
            username="tiantian";
            Password ="234";
            tel ="14325";
            ncikname ="tiantian";
        }else {
            username="lisi";
            Password ="123";
            tel ="14325";
            ncikname ="lisi";

        }

//00000
        user.setUserName(username);

        user.setUserTel(tel);

        user.setUserPassWord(Password);

        user.setUserNickName(ncikname);

        int i =  reviseUserService.reviseUser(user);
        System.out.println(i);
        return new CommonResult(ResultCode.SUCCESS,i);
    }

}
